import {post} from '@/utils/http'
import { get,httpInstance} from '@/utils/http'
// import request from '@/utils/request'
const baseUrl = 'http://localhost:6013/order-client/cms/workOrderInfo'

export function hometStatistics(){
  return post("yt-order/order-client/api/statistics/homePage")
}
// export function queryWorkOrderPageList(params) {
//   return request({
//     url: '/order-client/api/workOrderInfo/queryPageList',
//     method: 'post',
//     data: params // 注意：这里用 data 而不是 params，因为是用 @RequestBody 接收
//   })
// }
export function queryPageList(params) {

  return post(`${baseUrl}/queryPageList`, params,{
    headers:{
      'Content-Type':'application/json'
    }
  })
}
export function createWorkorder(formData) {

  return post(`${baseUrl}/create`, formData,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
export function updateWorkorder(params) {

  return post(`${baseUrl}/update`, params,{
    headers:{
      'Content-Type':'application/json'
    }
  })
}
export const getWorkorderDetail = (id) => {
  return post(`/workorder/detail/${id}`); // 假设接口路径为 /workorder/detail/:id
};

export function deleteOrder(id) {

  return post(`${baseUrl}/delete`,{}, {
    params:{ id : id },

  })
}
//获取可分配接单员
export function getEmployee(){
  return get('http://localhost:6013/order-client/cms/workOrderInfo//availableEmployees')
}
export function assignWorkorder(orderId, employeeId) {
   // 对于@RequestParam参数，应该使用params配置传递
 return httpInstance.post(
    'http://localhost:6013/order-client/cms/workOrderInfo/assign',
    {}, // 请求体，这里不需要
    {
      params: { // URL 查询参数
        orderId: orderId,
        employeeId: employeeId
      },
    }
  );
}
export function queryMessagePageList(params) {

  return post('http://localhost:6013/order-client/cms/adminNotification/queryPageList', params,{
    headers:{
      'Content-Type':'application/json'
    }
  })
}

export function getOrderDetail(id) {

  return post(`${baseUrl}/get`,{}, {
    params:{ id : id },

  })
}
export function updateStatus(id,status){
  return post(`${baseUrl}/updateStatus`,{},{
    params:{id,status}
  })
}
export function queryUserWorkorderList(params) {

  return post('http://localhost:6013/order-client/api/workOrderInfo/queryPageList', params,{
    headers:{
      'Content-Type':'application/json'
    }
  })
}
export function completeWorkorder(orderId, employeeId) {
   // 对于@RequestParam参数，应该使用params配置传递
 return httpInstance.post(
    'http://localhost:6013/order-client/api/employeeInfo/completeOrder',
    {}, // 请求体，这里不需要
    {
      params: { // URL 查询参数
        orderId: orderId,
        employeeId: employeeId
      },
    }
  );
}
export function rejectWorkorder(orderId, employeeId,reason) {
   // 对于@RequestParam参数，应该使用params配置传递
 return httpInstance.post(
    'http://localhost:6013/order-client/api/workOrderInfo/reject',
    {}, // 请求体，这里不需要
    {
      params: { // URL 查询参数
        id: orderId,
        employeeId: employeeId,
        reason:reason
      },
    }
  );
}
export function getUserStatistics(){
  return post("http://localhost:6013/order-client/api/employeeStatistics/comprehensiveStats")
}
export function queryFeedbackList(params) {

  return post('http://localhost:6013/order-client/api/customerFeedback/queryEmployeeFeedbackList', params)
}
export function queryCustomerList(params){
  return post('http://localhost:6013/order-client/cms/customerInfo/queryPageList',params,{
    headers:{
      'Content-Type':'application/json'
    }
  });
}
